<template>
  <uni-popup ref="popup" type="bottom" border-radius="10px 10px 0 0" background-color="#fff">
    <view v-for="item in props.actions" :key="item.key" class="py-15 text-15 text-center" @click="selectAction(item)">
      <text>{{ item.name }}</text>
    </view>
    <view class="w-full h-8 bg-[#f3f3f3]"></view>
    <view class="py-15 text-15 text-center" @click="close">
      <text>取消</text>
    </view>
  </uni-popup>
</template>

<script setup>
import { ref } from 'vue';

const props = defineProps({
  actions: {
    type: Array,
    default: () => [],
  },
});
const emits = defineEmits(['select']);
const popup = ref(null);
// 显示动作面板
function open() {
  popup.value.open();
}
// 关闭动作面板
function close() {
  popup.value.close();
}
// 选择动作
function selectAction(item) {
  emits('select', item);
  close();
}

defineExpose({
  open,
  close,
});
</script>
